// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueRouter from 'vue-router'
import Element from 'element-ui'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import VueAxios from 'vue-axios'
Vue.prototype.$http = VueAxios;
import VueLazyload from 'vue-lazyload'
Vue.use(VueRouter);
Vue.use(VueAwesomeSwiper)
Vue.use(VueLazyload)  
import { swiper, swiperSlide } from 'vue-awesome-swiper'


Vue.config.productionTip = false

import Home from  './components/Home/Home'//首页
import Navs from './components/Nav/Nav'
import About from  './components/Subsidies/Subsidies'//找补贴
import Active from './components/Active'//活动
import Mine from './components/Mine/Mine'//我的
import Ask from './components/ask/Ask'//付费提问

const routes = [
  {
    path:'/',
    component:Navs,
    children:[
        {
          path:'home/first',
          component:Home
        },
        {
          path:'home/subsidies',
          component:About
        },
        {
          path:'home/active',
          component:Active
        },
        {
          path:'home/mine',
          component:Mine
        }
    ]
  },
  {
    path:'/detail/:id',
    name:'detail',
    component:Ask
  }
]

const router = new VueRouter({
	routes
});

new Vue({
  el: '#app',
  data:{
   transitionName:"slide"
  },
  router,
  watch: {
    // 监视路由，参数为要目标路由和当前页面的路由
    '$route' (to, from){
      const toDepth = to.path.substring(0, to.path.length-2).split('/').length
      const fromDepth = from.path.substring(0, from.path.length-2).split('/').length
      this.transitionName = toDepth < fromDepth ? 'slide' : 'slide_back'
      }
  }
})
const app = new Vue({
  router
}).$mount('#app')
